<html xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">
    <title>编辑权限</title>

    <meta name="pragma" content="no-cache">
    <meta name="cache-control" content="no-cache">
    <meta name="expires" content="0">
    <link href="../../../../static/easyui/themes/insdep/easyui.css" rel="stylesheet" type="text/css">
    <link href="../../../../static/easyui/themes/insdep/easyui_animation.css" rel="stylesheet" type="text/css">
    <link href="../../../../static/easyui/themes/insdep/easyui_plus.css" rel="stylesheet" type="text/css">
    <link href="../../../../static/easyui/themes/insdep/insdep_theme_default.css" rel="stylesheet" type="text/css">
    <link href="../../../../static/easyui/themes/insdep/icon.css" rel="stylesheet" type="text/css">
    <link href="../../../../static/easyui/themes/color.css" rel="stylesheet" type="text/css">

    <link href="../../../../static/ztree/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css">
    <link href="../../../../static/css/common.css" rel="stylesheet" type="text/css">

    <script type="text/javascript" src="../../../../static/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="../../../../static/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../../../static/easyui/themes/insdep/jquery.insdep-extend.min.js"></script>
    <script type="text/javascript" src="../../../../static/ztree/jquery.ztree.all.min.js"></script>
    <script type="text/javascript" src="../../../../static/easyui/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../../../../static/kindeditor/kindeditor-all-min.js"></script>
</head>
<style type="text/css">
    .myselect {
        height: 30px;
    }
</style>

<body style="width:100%;max-width:100%;padding:10px 30px;">
<form id="form" method="post">
    <strong>主要信息</strong>
    <section class="info-section">

        <table id="tb">
            <tr>
                <td class="text-title">负责人</td>
                <td class="text-content">
                    <input type="hidden" name="id" >
                    <input type="hidden" name="busiVO.createtime" value="${busiVO.createtime }">
                    <input type="hidden" name="busiVO.createById" value="${busiVO.createById }">
                    <select class="myselect" name="ownerUserId">
                        <option value="-1" th:each="user:${users}" th:value="${user?.id}" th:text="${user?.username}">
                            请选择负责人
                        </option>
                    </select>
                </td>
                <td class="text-title">客户</td>
                <td class="text-content">
                    <select class="myselect" name="customerId">
                        <option value="-1" th:each="customer:${customers}" th:value="${customer?.id}"
                                th:text="${customer?.name}">
                            请选择客户
                        </option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="text-title">商机金额</td>
                <td class="text-content">
                    <input type="text" name="totalPrice"
                           class="easyui-textbox theme-textbox-radius" data-options="required:false">
                </td>
                <td class="text-title">商机名</td>
                <td class="text-content">
                    <input type="text" name="name"
                           class="easyui-textbox theme-textbox-radius" data-options="required:false">
                </td>
            </tr>
            <tr>
                <td class="text-title">联系人</td>
                <td class="text-content">
                    <select class="myselect" name="contactsId">
                        <option value="-1" th:each="contact:${contacts}" th:value="${contact?.id}"
                                th:text="${contact?.csname}">
                            请选择联系人
                        </option>
                    </select>
                </td>

            </tr>
            <tr>
                <td class="text-title">合同签订地址</td>
                <td class="text-content" colspan="3">
                    <input type="text" style="width:550px;" name="contractAddress"
                           class="easyui-textbox theme-textbox-radius" data-options="required:false">
                </td>
            </tr>
            <tr>
                <td class="text-title">商机类型</td>
                <td class="text-content">
                    <input name="type"
                           class="easyui-textbox theme-textbox-radius" data-options="required:false"/>
                </td>
                <td class="text-title">状态</td>
                <td class="text-content">
                    <select class="myselect" name="statusId">
                        <option value="-1" th:each="statuse:${statuses}" th:value="${statuse?.id}"
                                th:text="${statuse?.name}">
                            请选择状态
                        </option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="text-title">商机来源</td>
                <td class="text-content">
                    <input name="origin"
                           class="easyui-textbox theme-textbox-radius" data-options="required:false"/>
                </td>
                <td class="text-title">赢单率</td>
                <td class="text-content">
                    <input type="text" name="gainRate"
                           class="easyui-textbox theme-textbox-radius" data-options="required:false">
                </td>
            </tr>
            <tr>
                <td class="text-title">预定成交价</td>
                <td class="text-content">
                    <input type="text" name="estimatePrice"
                           class="easyui-textbox theme-textbox-radius" data-options="required:true">
                </td>
                <td class="text-title">下次联系时间</td>
                <td class="text-content">
                    <input class="easyui-datetimebox" name="nextstepTime"
                           data-options="required:false,showSeconds:false" style="width:150px">
                </td>
            </tr>
            <tr>
                <td class="text-title">下次联系内容</td>
                <td class="text-content">
                    <input type="text" name="nextstep"
                           class="easyui-textbox theme-textbox-radius" data-options="required:false">
                </td>

            </tr>

        </table>

    </section>
    <strong>附加信息</strong>
    <section class="info-section">
        <table>
            <tr>
                <td class="text-title">备注</td>
                <td class="text-content">
                    <textarea name="description" rows="5" style="width:80%;"
                              ></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;margin-top: 10px;">
                    <a href="javascript:void(0);" id="saveBtn" class="easyui-linkbutton button-primary"
                       style="margin-left:-70px;">保存</a>
                    <a href="javascript:void(0);" id="resetBtn" class="easyui-linkbutton button-danger"
                       style="margin-left:30px;">重置</a>
                </td>
            </tr>
        </table>
    </section>
</form>

<script type="text/javascript">
    $(function () {
        //给负责人下拉框填充选项
        /*$.post(
                  "echoEditBusiness",
                  function(data){
                      if(data&&data.data){
                          $.each(data.data,function(index,obj){
                              var option;
                              if("${sessionScope.user.id}"==obj.id){
                                  option=$("<option value='"+obj.id+"' selected>"+obj.username+"</option>");
                              }else{
                                  option=$("<option value='"+obj.id+"'>"+obj.username+"</option>");
                              }
                              $("select[name='busiVO.ownerId']").append(option);

                          })
                      }
                  },"json"
         )*/
        //给客户下拉框填充选项
        /*$.post(
                  "echoEditBusiness",
                  function(data){
                      if(data&&data.data){
                          $.each(data.data,function(index,obj){
                              var option;
                              if("${busiVO.customerId}"==obj.id){
                                  option=$("<option value='"+obj.id+"' selected>"+obj.name+"</option>");
                              }else{
                                  option=$("<option value='"+obj.id+"'>"+obj.name+"</option>");
                              }
                              $("select[name='busiVO.customerId']").append(option);
                          })
                      }
                  },"json"
         )*/
        // if("${busiVO.customerId}"){
        // 	fillContacts("${busiVO.customerId}");
        // }
        //给商机类型下拉框填充选项
        /*$.post(
                  "system/dict/DictAction_findByTypecode.action",
                  {
                      "typecode":"businessType"
                  },
                  function(data){
                      if(data&&data.data){
                          $.each(data.data,function(index,obj){
                              var option;
                              if(obj.dictname=="${busiVO.type}"){
                                  option=$("<option value='"+obj.dictname+"' selected>"+obj.dictname+"</option>");
                              }else{
                                  option=$("<option value='"+obj.dictname+"'>"+obj.dictname+"</option>");
                              }
                              $("select[name='busiVO.type']").append(option);
                          })
                      }
                  },"json"
         )*/
        //给商机状态下拉框填充选项
        /*$.post(
                  "system/dict/DictAction_findByTypecode.action",
                  {
                      "typecode":"businessStatus"
                  },
                  function(data){
                      if(data&&data.data){
                          $.each(data.data,function(index,obj){
                              var option;
                              if(obj.id=="${busiVO.businessStatusId}"){
                                  option=$("<option value='"+obj.id+"' selected>"+obj.dictname+"</option>");
                              }else{
                                  option=$("<option value='"+obj.id+"'>"+obj.dictname+"</option>");
                              }
                              $("select[name='busiVO.businessStatusId']").append(option);
                          })
                      }
                  },"json"
         )*/
        //给商机来源下拉框填充选项
        /*$.post(
                  "system/dict/DictAction_findByTypecode.action",
                  {
                      "typecode":"businessOrigin"
                  },
                  function(data){
                      if(data&&data.data){
                          $.each(data.data,function(index,obj){
                              var option;
                              if(obj.dictname=="${busiVO.origin}"){
                                  option=$("<option value='"+obj.dictname+"' selected>"+obj.dictname+"</option>");
                              }else{
                                  option=$("<option value='"+obj.dictname+"'>"+obj.dictname+"</option>");
                              }
                              $("select[name='busiVO.origin']").append(option);
                          })
                      }
                  },"json"
         )*/


    })
    //监听客户下拉框的事件，若更改客户则重新给联系人下拉框填充选项
    /*$("select[name='busiVO.customerId']").on("change",function(event){
        var custId=$(this).val();
        fillContacts(custId);
    })*/

    //给联系人下拉框填充选项的方法
    /*function fillContacts(id){
        $.post(
                  "manage/contacts/ContactsAction_findByCustomer.action",
                  {
                      "customer.customerid":id
                  },
                  function(data){
                      if(data&&data.data){
                          $("select[name='busiVO.contactsId']").empty();
                          if(data.data.length){
                              $.each(data.data,function(index,obj){
                                  var option;
                                  if(obj.id=="${busiVO.contactsId}"){
                                      option=$("<option value='"+obj.id+"' selected>"+obj.name+"</option>");
                                  }else if(obj.isFirst){
                                      option=$("<option value='"+obj.id+"' selected>"+obj.name+"(首要)</option>");
                                  }else{
                                      option=$("<option value='"+obj.id+"'>"+obj.name+"</option>");
                                  }
                                  $("select[name='busiVO.contactsId']").append(option);
                              })
                          }else{
                              $("select[name='busiVO.contactsId']").append("<option value='-1'>暂无数据</option>");
                          }
                      }
                  },"json"
         )
    }*/


    $(function () {
        //当页面加载完毕初始化树状下拉列表
        $("#parent").combotree({
            url: "system/function/FunctionAction_findTree.action",
            method: "get",
            loadFilter: function (data) {//resultData {success:true,message:"",data:[]}
                if (data && data.success) {
                    return data.data;
                }
                return null;
            }
        });

    });

    $(function () {
        //重置按钮
        $("#resetBtn").on("click", function (event) {
            $("#form").form("reset");
        });
        //保存按钮
        $("#saveBtn").on("click", function (event) {
            $("#form").form("submit", {
                url: "addBusiness",
                onSubmit: function () {
                    //对表单进行数据校验,如果未通过校验，返回false，阻止表单提交
                    return $(this).form("validate");
                },
                success: function (data) {
                    //data未服务器端返回的字符串数据，eval将字符串数据转换为json对象
                    data = eval("(" + data + ")");
                    if (data.success) {
                        $.messager.alert("提示", data.msg, "info", function () {
                            parent.closeTopWindow();
                        })
                    } else {
                        $.messager.alert("提示", data.msg, "info")
                    }
                }
            });
        });


    });
</script>
</body>
</html>
